<!DOCTYPE html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
  <title>resolvePath Imports</title>
  <script src="../../../webcomponentsjs/webcomponents.js"></script>
  <link rel="import" href="../../polymer.html">
  <script src="../../../tools/test/htmltest.js"></script>
  <script src="../../../tools/test/chai/chai.js"></script>
  <link rel="import" href="resolve/x-resolve-import.html">
</head>
<body>
  <x-resolve-import id="xri"></x-resolve-import>
  <x-resolve-import-ap id="xri-ap"></x-resolve-import-ap>

  <script>
    var assert = chai.assert;
    addEventListener('polymer-ready', function() {
      var d = location.href.split('/').slice(0, -1).join('/') + '/';
      var xri = document.querySelector('#xri');
      assert.equal(xri.$.image.src, new URL('resolve/images/foo', document.baseURI).href);
      assert.equal(xri.resolvePath('foo.js'), d + 'resolve/foo.js');
      assert.equal(xri.resolvePath('foo/bar'), d + 'resolve/foo/bar');
      assert.equal(xri.resolvePath('http://example.com/foo'), 'http://example.com/foo');
      var xriap = document.querySelector('#xri-ap');
      assert.equal(xriap.resolvePath('foo.js'), d + 'resolve/foo/bar/baz/foo.js');
      assert.equal(xriap.resolvePath('foo/bar/foo.js'), d +
                   'resolve/foo/bar/baz/foo/bar/foo.js');
      assert.equal(xriap.resolvePath('http://example.com/foo'), 'http://example.com/foo');
      done();
    });
  </script>
</body>
</html>
